package com.llt.order.controller;

import com.llt.product.model.ProductDetail;
import com.llt.product.api.ProductApi;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("feign")
public class FeignController {

    @Resource
    private ProductApi productApi;

    @RequestMapping("/o1")
    public String p1(Integer id, String userName, HttpServletResponse response){

        // 测试 gateway 中的 Retry 配置
        response.setStatus(502);

        log.info("username：{}", userName);

        return productApi.p1(id);
    }

    @RequestMapping("/o2")
    public String p2(Integer id, String name){
        return productApi.p2(id, name);
    }

    // 接收对象
    @RequestMapping("/o3")
    public String p3(ProductDetail productInfo){
        return productApi.p3(productInfo);
    }

    // 接收 json
    @RequestMapping("/o4")
    public String p4(@RequestBody ProductDetail productInfo){
        return productApi.p4(productInfo);
    }


}
